import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:wu_you/model/user/user_model.dart';
import 'package:wu_you/res/colors.dart';
import 'package:wu_you/state/bloc/http_bloc.dart';
import 'package:wu_you/state/bloc/user_bloc.dart';
import 'package:wu_you/widgets/http_list_widget.dart';

///待释放积分列表
class PointsMarketPage extends StatefulWidget{
  @override
  PointsMarketPageState createState() => PointsMarketPageState();
}
class PointsMarketPageState extends State<PointsMarketPage>{
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('待释放积分'),
      ),
      body: HttpListWidget<PointsSetModel, PointsListBloc>(
            creator: (context) => PointsListBloc(),
            onObtainData: (context, page) {
              BlocProvider.of<PointsListBloc>(context).add(PageSizeHttpEvent(1,1000));
            },
            successBuilder: (context, data) {
              return ListView.builder(
                itemCount: data.length,
                itemBuilder: (context, index) {
                  PointsSetModel item = data[index];
                  return Container(
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius:
                      BorderRadius.all(Radius.circular(4)),
                    ),
                    padding: EdgeInsets.all(8),
                    margin: EdgeInsets.only(left: 8,right: 8,top: 5),
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        RichText(
                            text: TextSpan(children: [
                              TextSpan(
                                  text: "订单号：",
                                  style: TextStyle(
                                      color: AppColors.textHintColor, fontSize: 14)),
                              TextSpan(
                                  text: "${item.no}",
                                  style: TextStyle(
                                      color: AppColors.textColor,
                                      fontSize: 15,
                                      fontWeight: FontWeight.normal))
                            ])),
                        SizedBox(height: 8,),
                        Divider(),
                        SizedBox(height: 8,),
                        RichText(
                            text: TextSpan(children: [
                              TextSpan(
                                  text: "下单金额：",
                                  style: TextStyle(
                                      color: AppColors.textHintColor, fontSize: 14)),
                              TextSpan(
                                  text: "${item.money}",
                                  style: TextStyle(
                                      color: AppColors.primaryColor,
                                      fontSize: 15,
                                      fontWeight: FontWeight.bold))
                            ])),
                        SizedBox(height: 6,),
                        RichText(
                            text: TextSpan(children: [
                              TextSpan(
                                  text: "总释放金额：",
                                  style: TextStyle(
                                      color: AppColors.textHintColor, fontSize: 14)),
                              TextSpan(
                                  text: "${item.total}",
                                  style: TextStyle(
                                      color: AppColors.primaryColor,
                                      fontSize: 15,
                                      fontWeight: FontWeight.bold))
                            ])),
                        SizedBox(height: 6,),
                        RichText(
                            text: TextSpan(children: [
                              TextSpan(
                                  text: "剩余释放金额：",
                                  style: TextStyle(
                                      color: AppColors.textHintColor, fontSize: 14)),
                              TextSpan(
                                  text: "${item.cost}",
                                  style: TextStyle(
                                      color: AppColors.primaryColor,
                                      fontSize: 15,
                                      fontWeight: FontWeight.bold))
                            ])),
                      ],
                    )
                  );
                },
              );
            }
        )
    );
  }

}